package com.stylefeng.guns.biz.data.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.biz.data.model.TDataClick;
import com.stylefeng.guns.biz.data.service.ITDataClickService;
import com.stylefeng.guns.biz.hot.model.HotList;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.log.LogObjectHolder;

/**
 * 数据报表控制器
 *
 * @author fengshuonan
 * @Date 2018-07-04 17:26:21
 */
@Controller
@RequestMapping("/tDataClick")
public class TDataClickController extends BaseController {

    private String PREFIX = "/app/tDataClick/";

    @Autowired
    private ITDataClickService tDataClickService;

    /**
     * 跳转到数据报表首页
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "tDataClick.html";
    }

    /**
     * 跳转到添加数据报表
     */
    @RequestMapping("/tDataClick_add")
    public String tDataClickAdd() {
        return PREFIX + "tDataClick_add.html";
    }

    /**
     * 跳转到修改数据报表
     */
    @RequestMapping("/tDataClick_update/{tDataClickId}")
    public String tDataClickUpdate(@PathVariable Integer tDataClickId, Model model) {
        TDataClick tDataClick = tDataClickService.selectById(tDataClickId);
        model.addAttribute("item",tDataClick);
        LogObjectHolder.me().set(tDataClick);
        return PREFIX + "tDataClick_edit.html";
    }

    /**
     * 获取数据报表列表
     */
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(String appid) {
    	
    	EntityWrapper<TDataClick> wrapper=new EntityWrapper<>();
    	wrapper.eq("app_id", appid);
    	
        return tDataClickService.selectList(wrapper);
    }

    /**
     * 新增数据报表
     */
    @RequestMapping(value = "/add")
    @ResponseBody
    public Object add(TDataClick tDataClick) {
        tDataClickService.insert(tDataClick);
        return SUCCESS_TIP;
    }

    /**
     * 删除数据报表
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public Object delete(@RequestParam Integer tDataClickId) {
        tDataClickService.deleteById(tDataClickId);
        return SUCCESS_TIP;
    }

    /**
     * 修改数据报表
     */
    @RequestMapping(value = "/update")
    @ResponseBody
    public Object update(TDataClick tDataClick) {
        tDataClickService.updateById(tDataClick);
        return SUCCESS_TIP;
    }

    /**
     * 数据报表详情
     */
    @RequestMapping(value = "/detail/{tDataClickId}")
    @ResponseBody
    public Object detail(@PathVariable("tDataClickId") Integer tDataClickId) {
        return tDataClickService.selectById(tDataClickId);
    }
}
